package com.cmty256.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * Knife4j 接口文档配置
 * https://doc.xiaominfo.com/knife4j/documentation/get_start.html
 *
 * @author chenmeng
 */
@Configuration
@EnableSwagger2
@Profile("dev")
public class Knife4jConfig {

    /**
     * 访问路径示例：http://localhost:8101/cmuser/doc.html
     */
    @Bean
    public Docket cmuserApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("cm-user Module API")
                        .description("接口文档描述 - cm-user 模块")
                        .version("1.0")
                        .build())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cmty256.cmuser.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    // @Bean
    // public Docket cmauthApi() {
    //     return new Docket(DocumentationType.SWAGGER_2)
    //             .apiInfo(new ApiInfoBuilder()
    //                     .title("cm-auth Module API")
    //                     .description("接口文档描述 - cm-auth 模块")
    //                     .version("1.0")
    //                     .build())
    //             .select()
    //             .apis(RequestHandlerSelectors.basePackage("com.cmty256.cmauth.controller"))
    //             .paths(PathSelectors.any())
    //             .build();
    // }
}